﻿<Panels:ClosableControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:ViewModel="clr-namespace:MediaBrowser.Gui.ViewModels"
    xmlns:Panels="clr-namespace:MediaBrowser.CustomControls.Panels;assembly=MediaBrowser.CustomControls"
    xmlns:Converters="clr-namespace:MediaBrowser.Gui.Converters"
    xmlns:julmar="http://www.julmar.com/wpfhelpers"
    xmlns:MediaBrowser_Controls="clr-namespace:MediaBrowser.CustomControls;assembly=MediaBrowser.CustomControls"
    mc:Ignorable="d" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
    x:Name="closableControl" x:Class="MediaBrowser.Gui.Views.UserCtrlPlayer"
    d:DesignWidth="600" d:DesignHeight="400">

    <Panels:ClosableControl.Resources>

        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/MediaBrowser.Gui;Component/Themes/PlayerDictionary.xaml"/>
            </ResourceDictionary.MergedDictionaries>

            <Converters:IsNullConverter x:Key="isNullConverter" />
            <Converters:StringToDragBitmapConverter x:Key="stringToDragBitmapConverter" />
            <ViewModel:ViewModelLocator x:Key="Locator" d:IsDataSource="True"/>
        </ResourceDictionary>
    </Panels:ClosableControl.Resources>
    
    <Panels:ClosableControl.Triggers>
    </Panels:ClosableControl.Triggers>


    <Grid DataContext="{Binding Movies, Mode=OneWay, Source={StaticResource Locator}}">
        <Border HorizontalAlignment="Stretch" Margin="0,0,0,0" Width="Auto" BorderThickness="3,3,3,3" 
                CornerRadius="4,4,4,4" Background="{DynamicResource BckWindow}">

            <Grid >
                <Grid.RowDefinitions>
                    <RowDefinition Height="20"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="40"/>
                </Grid.RowDefinitions>
                <Border Grid.Row="0" BorderThickness="1,1,1,0" CornerRadius="2,2,0,0"  Background="{DynamicResource BackGrdCustom}">
                    <Grid>
                        <Label Margin="5,0,0,0" VerticalAlignment="Center" Foreground="White" Content="Player"/>
                        <Image x:Name="imageCross" Width="10" Height="10" Grid.Row="0" HorizontalAlignment="Right" 
                               Source="/MediaBrowser.Gui;Component/Images/cross2.png" PreviewMouseDown="Close_Event" 
                               RenderTransformOrigin="0.5,0.5" Margin="0,0,5,0" >
                            <Image.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform/>
                                    <SkewTransform/>
                                    <RotateTransform/>
                                    <TranslateTransform/>
                                </TransformGroup>
                            </Image.RenderTransform>
                        </Image>
                    </Grid>
                </Border>

                <Grid Grid.Row="1" Background="Black">
                    <MediaElement x:Name="mediaElement" d:IsHidden="True" Source="{Binding CurrentMedia.UrlContent}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="MediaOpened">
                                <julmar:InvokeCommand Command="{Binding MediaOpenedCommand, Mode=Default}" CommandParameter="{Binding ElementName=mediaElement, Mode=OneWay}"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                        <julmar:EventCommander.Mappings>
                            <julmar:CommandEvent Command="{Binding MediaFailedCommand}" Event="MediaFailed" CommandParameter="{Binding}" />
                        </julmar:EventCommander.Mappings>
                    </MediaElement>
                </Grid>


                <Border Grid.Row="2" Margin="0" CornerRadius="0,0,2,2">
                    <Border.Background>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="#CC4B5059" Offset="0"/>
                            <GradientStop Color="#CC838C9B" Offset="0.985"/>
                        </LinearGradientBrush>
                    </Border.Background>

                    <Grid Margin="10,5">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="85"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="30"/>
                        </Grid.ColumnDefinitions>

                        <StackPanel Orientation="Horizontal" Grid.Column="0" >
                            <Button Style="{StaticResource smartButton}" Content="{StaticResource playSign}" Command="{Binding PlayVideoCommand}" Height="24" Width="24"/>
                            <Button x:Name="button" Style="{StaticResource smartButton}" Content="{StaticResource pauseSign}" Command="{Binding PauseVideoCommand}"  Height="24" Width="24" Margin="5,0,0,0"/>
                            <Button Style="{StaticResource smartButton}" Content="{StaticResource stopSign}" Command="{Binding StopVideoCommand}" Height="24" Width="24" Margin="5,0,0,0"/>
                        </StackPanel>

                        <StackPanel Orientation="Vertical" Grid.Column="1" Margin="10,0,0,0" VerticalAlignment="Bottom">
                            <Slider Template="{DynamicResource TrackSlider}" IsMoveToPointEnabled="True"
                                    Maximum="{Binding TotalDuration}" Value="{Binding CurrentPosition, Mode=TwoWay}"/>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" Margin="0,2,0,0">
                                <Slider Maximum="1" LargeChange="0.5" Value="{Binding Volume, ElementName=mediaElement, Mode=TwoWay}"  Template="{DynamicResource VolumeSlider}" Width="80" Height="16" Margin="0,4,0,0" IsMoveToPointEnabled="True" />
                                <TextBlock x:Name="ProgressDisplay" Text="{Binding CurrentProgress}" VerticalAlignment="Center" Margin="10,0,0,0" Foreground="#FFFAF7F7"/>
                                <TextBlock Text="{Binding StatusPlayer}" VerticalAlignment="Center" Margin="10,0,0,0" Foreground="#FFEE0F0F" FontWeight="Bold"/>
                            </StackPanel>
                        </StackPanel>

                        <Image x:Name="imageLarge" Cursor="Hand" Grid.Column="2" Width="18" Height="18" Grid.Row="0" HorizontalAlignment="Right" 
                               Source="/MediaBrowser.Gui;Component/Images/maxi.png" RenderTransformOrigin="0.5,0.5" Margin="0" 
                               VerticalAlignment="Bottom" ToolTip="Agrandir/réduire écran" PreviewMouseDown="Size_Event">
                            <Image.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform/>
                                    <SkewTransform/>
                                    <RotateTransform/>
                                    <TranslateTransform/>
                                </TransformGroup>
                            </Image.RenderTransform>
                        </Image>
                    </Grid>



                </Border>
            </Grid>
        </Border>
    </Grid>
</Panels:ClosableControl>
